package com.lnsf.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lnsf.dao.EmployeeDao;
import com.lnsf.entity.Employee;
import com.lnsf.service.EmpService;


@Service
public class EmpServiceImpl implements EmpService{
	
	@Autowired
	private EmployeeDao employeeDao;

	@Override
	public List<Employee> getAllEmployee() {
		
		List<Employee> employees = employeeDao.getAllEmployee();
		return employees;
	}

	
	@Override
	public Employee getEmployeeById(int empno) {
		
		Employee employee = employeeDao.getEmployeeById(empno);
		return employee;
	}
	
	
	@Override
	public int addEmployee(Employee emp) {
		int i = 0;
		try {
			
			i = employeeDao.addEmployee(emp);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return i;
	}


	@Override
	public int updateEmployee(Employee emp) {
		int i = 0;
		try {
			i = employeeDao.updateEmployee(emp);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return i;
	}


	@Override
	public int deleteEmployee(int empno) {
		int i = 0;
		try {
			 i = employeeDao.deleteEmployee(empno);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return i;
		
	}
	
	public int getCurrentEmpNo(){
		return employeeDao.getMaxEmpNo()+1;
	}
	
	
	
	
	public EmployeeDao getEmployeeDao() {
		return employeeDao;
	}

	public void setEmployeeDao(EmployeeDao employeeDao) {
		this.employeeDao = employeeDao;
	}


	



	
	
	
	
}
